var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(e, t) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(e, t) {
        e.__proto__ = t;
    } || function(e, t) {
        for (var o in t) t.hasOwnProperty(o) && (e[o] = t[o]);
    })(e, t);
}, function(e, t) {
    function n() {
        this.constructor = e;
    }
    o(e, t), e.prototype = null === t ? Object.create(t) : (n.prototype = t.prototype, 
    new n());
}), a = this && this.__decorate || function(e, t, o, n) {
    var s, i = arguments.length, a = i < 3 ? t : null === n ? n = Object.getOwnPropertyDescriptor(t, o) : n;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) a = Reflect.decorate(e, t, o, n); else for (var r = e.length - 1; 0 <= r; r--) (s = e[r]) && (a = (i < 3 ? s(a) : 3 < i ? s(t, o, a) : s(t, o)) || a);
    return 3 < i && a && Object.defineProperty(t, o, a), a;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("Global"), s = e("AudioManager"), c = e("GameData"), l = e("EggsManager"), d = e("DataManager"), u = e("LoadManager"), p = e("UIManager"), h = e("WebManager"), f = cc._decorator, g = f.ccclass, m = f.property, y = function(t) {
    function e() {
        var e = null !== t && t.apply(this, arguments) || this;
        return e.personView = null, e.shadow = null, e.moonLight = null, e.moonDark = null, 
        e.time = 3, e.count = 0, e.total = 9, e.idx = 10, e;
    }
    return i(e, t), e.prototype.onLoad = function() {
        cc.systemEvent.on("refresh_person_skin", this.doRefresh, this);
    }, e.prototype.onDestroy = function() {
        cc.systemEvent.off("refresh_person_skin", this.doRefresh, this), s.default.getInstance().playBg("背景");
    }, e.prototype.onClick = function() {
        var t, o = this;
        -1 == l.default.getInstance().checkEggPerson(this.idx) && (0 == this.count && this.scheduleOnce(this.doTimer, this.time), 
        this.count < this.total ? (h.default.getInstance().sentLog("触发皮肤彩蛋id:" + this.idx), 
        s.default.getInstance().playAudio("按钮2"), this.count++) : (h.default.getInstance().sentLog("获得皮肤彩蛋id:" + this.idx), 
        s.default.getInstance().playAudio("皮肤出现"), this.moonDark.active = !1, this.shadow.parent = cc.Canvas.instance.node, 
        this.shadow.active = !0, this.moonLight.parent = cc.Canvas.instance.node, this.moonLight.active = !0, 
        t = new cc.Node().addComponent(sp.Skeleton), u.default.getInstance().loadRes({
            url: "skeleton/皮肤" + r.G.eggPersonModelList[this.idx].m + "/change",
            type: sp.SkeletonData
        }).then(function(e) {
			t.premultipliedAlpha = false,
            t.skeletonData = e, t.node.setPosition(cc.v2(-800, -360)), t.node.parent = cc.Canvas.instance.node, 
            t.node.scale = .5, t.node.zIndex = 1, t.setAnimation(0, "animation", !1), s.default.getInstance().playBg("彩蛋皮肤" + r.G.eggPersonModelList[o.idx].m), 
            cc.tween(t.node).to(2, {
                position: cc.v3(40, 140)
            }).call(function() {
                o.shadow.parent = o.node, o.shadow.active = !1, o.moonLight.parent = o.node, o.moonLight.active = !1, 
                t.setCompleteListener(null), t.node.destroy(), p.default.getInstance().loadPopPnl("egg_reward", {
                    type: r.RewardType.SKIN,
                    idx: o.idx
                });
            }).start();
        }), l.default.getInstance().updateEggPerson(this.idx), c.GD.personIdx = -1 - this.idx, 
        c.GD.eggsHintState = 1, d.default.getInstance().save(), cc.systemEvent.off("refresh_person_skin", this.doRefresh, this)));
    }, e.prototype.start = function() {
        this.doRefresh();
    }, e.prototype.doRefresh = function() {
        16 == this.personView.personIdx ? this.node.active = !0 : this.node.active = !1;
    }, e.prototype.doTimer = function() {
        this.count = 0;
    }, e.prototype.stopTimer = function() {
        this.unschedule(this.doTimer);
    }, a([ m(cc.Node) ], e.prototype, "shadow", void 0), a([ m(cc.Node) ], e.prototype, "moonLight", void 0), 
    a([ m(cc.Node) ], e.prototype, "moonDark", void 0), a([ g ], e);
}(cc.Component);

n.default = y;